<?php
/**
 * Auth_model Class
 *
 */
class Role_model extends CI_Model {
	/**
	 * Constructor
	 */
	function Role_model()
		{
			parent::__construct();
		}
		
	// Inisialisasi nama tabel user
	var $table = 'role';
	
	function get_all_role(){
		$this->db->select('*')->from('role');
		
		return $this->db->get();
	}
	
	function insert_role($arr){
		$this->db->insert("role", $arr);
	}
	
	function delete_role($id){
		return $this->db->where('ID_ROLE',$id)
					->delete('role');
		
	}
	
	function get_role($id){
		return $this->db->select('*')
				->from('role')
				->where('ID_ROLE', $id)
				->get();
	}
	
	function update_role($id, $arr){
		$this->db->where('ID_ROLE',$id);
		$this->db->update('role',$arr);
	}
	
	function get_all_fitur(){
		return $this->db->select('*')
				->from('fitur')
				->get();
	}
	
	function is_fitur_available($id_fitur, $id_role){
		$result = $this->db->select('*')
				->from('hak_akses')
				->where('ID_ROLE', $id_role)
				->where('ID_FITUR', $id_fitur)
				->get();
				
		if($result->num_rows > 0) return true;
		else return false;
	}
	
	function delete_hak_akses($id){
		$this->db->where('ID_ROLE',$id);
		$this->db->delete('hak_akses');
	}
	
	function update_hak_akses($arr){
		$this->db->insert('hak_akses', $arr);
	}
}
// END Auth_model Class

/* End of file Auth_model.php */ 
/* Location: ./system/application/model/Auth_model.php */